// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_c;

import android.content.*;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
import android.text.TextUtils;
import com.nnee.p_b.p_a.cls_d;
import com.nnee.p_pr.p_atom.cls_o;
import com.nnee.p_pr.p_atom.cls_u;
import com.nnee.p_pr.p_prov.cls_ac;
import com.nnee.p_pr.p_prov.e;
import java.util.*;

public class cls_n
{

    public n()
    {
    }

    public static Cursor a(Context context, String s, String s1)
    {
        String s2 = null;
        if(context != null && !TextUtils.isEmpty(s) && s1 != null)
        {
            String s3 = (new StringBuilder()).append("account = '").append(s).append("' AND ").append("uid").append(" in ").append("(").append(s1).append(")").toString();
            s2 = context.getContentResolver().query(e.b, a, s3, s2, s2);
        }
        return s2;
    }

    public static List a(Context context, String s)
    {
        Object obj = null;
        if(context == null) goto _L2; else goto _L1
_L1:
        Cursor cursor;
        ContentResolver contentresolver = context.getContentResolver();
        android.net.Uri uri = e.b;
        String as[] = f;
        String as1[] = new String[1];
        as1[0] = s;
        cursor = contentresolver.query(uri, as, "account=?", as1, ((String) (obj)));
        if(cursor == null) goto _L2; else goto _L3
_L3:
        if(!cursor.moveToFirst()) goto _L5; else goto _L4
_L4:
        obj = new LinkedList();
        boolean flag;
        do
        {
            ((List) (obj)).add(cursor.getString(0));
            flag = cursor.moveToNext();
        } while(flag);
        cursor.close();
_L2:
        return ((List) (obj));
_L5:
        cursor.close();
        if(true) goto _L2; else goto _L6
_L6:
        Exception exception;
        exception;
        cursor.close();
        throw exception;
    }

    public static void a(Context context, String s, String s1, boolean flag)
    {
        if(!TextUtils.isEmpty(s) && !TextUtils.isEmpty(s1))
            if(flag)
            {
                ContentValues contentvalues = new ContentValues();
                contentvalues.put("account", s);
                contentvalues.put("uid", s1);
                context.getContentResolver().insert(e.b, contentvalues);
            } else
            {
                String s2 = (new StringBuilder()).append("account = '").append(s).append("' ").append(" AND ").append("uid").append(" = '").append(s1).append("'").toString();
                context.getContentResolver().delete(e.b, s2, null);
            }
    }

    public static void a(Context context, String s, LinkedList linkedlist)
    {
        if(!TextUtils.isEmpty(s) && linkedlist != null && !linkedlist.isEmpty())
        {
            StringBuilder stringbuilder = new StringBuilder();
            Iterator iterator = linkedlist.iterator();
            do
            {
                if(!iterator.hasNext())
                    break;
                cls_o o1 = (o)iterator.next();
                if(o1 != null)
                    stringbuilder.append("'").append(o1.a()).append("'").append(",");
            } while(true);
            if(stringbuilder.length() > 0)
                stringbuilder.deleteCharAt(-1 + stringbuilder.length());
            c(context, s, stringbuilder.toString());
        }
    }

    public static void a(Context context, String s, List list)
    {
        if(context != null && list != null && list.size() > 0)
        {
            List list1 = a(com.nnee.p_b.p_a.cls_d.h().a(), s);
            if(list1 != null && list1.size() > 0)
            {
                HashMap hashmap = new HashMap();
                u u2;
                for(Iterator iterator = list.iterator(); iterator.hasNext(); hashmap.put(u2.V(), u2))
                    u2 = (cls_u)iterator.next();

                Iterator iterator1 = list1.iterator();
                do
                {
                    if(!iterator1.hasNext())
                        break;
                    cls_u u1 = (u)hashmap.get((String)iterator1.next());
                    if(u1 != null)
                        u1.b(true);
                } while(true);
            }
        }
    }

    public static void a(Context context, ArrayList arraylist, String s)
    {
        if(context != null && arraylist != null && arraylist.size() != 0) goto _L2; else goto _L1
_L1:
        return;
_L2:
        SQLiteDatabase sqlitedatabase;
        SQLiteStatement sqlitestatement;
        sqlitedatabase = ac.a(context).getWritableDatabase();
        sqlitedatabase.beginTransaction();
        sqlitestatement = null;
        StringBuilder stringbuilder = new StringBuilder();
        stringbuilder.append(" INSERT INTO ");
        stringbuilder.append("offline");
        stringbuilder.append("(");
        stringbuilder.append("account");
        stringbuilder.append(",");
        stringbuilder.append("uid");
        stringbuilder.append(")");
        stringbuilder.append(" VALUES(");
        stringbuilder.append("?,?");
        stringbuilder.append(");");
        sqlitestatement = sqlitedatabase.compileStatement(stringbuilder.toString());
        for(Iterator iterator = arraylist.iterator(); iterator.hasNext(); sqlitestatement.execute())
        {
            String s1 = (String)iterator.next();
            sqlitestatement.bindString(1, s);
            sqlitestatement.bindString(2, s1);
        }

        break MISSING_BLOCK_LABEL_206;
        Exception exception1;
        exception1;
        exception1.printStackTrace();
        if(sqlitestatement != null)
            sqlitestatement.close();
        sqlitedatabase.endTransaction();
          goto _L1
        sqlitedatabase.setTransactionSuccessful();
        if(sqlitestatement != null)
            sqlitestatement.close();
        sqlitedatabase.endTransaction();
          goto _L1
        Exception exception;
        exception;
        if(sqlitestatement != null)
            sqlitestatement.close();
        sqlitedatabase.endTransaction();
        throw exception;
    }

    public static int b(Context context, String s)
    {
        int i;
        if(context == null || TextUtils.isEmpty(s))
        {
            i = 0;
        } else
        {
            ContentResolver contentresolver = context.getContentResolver();
            android.net.Uri uri = e.b;
            String as[] = a;
            String as1[] = new String[1];
            as1[0] = s;
            Cursor cursor = contentresolver.query(uri, as, "account=?", as1, null);
            if(cursor == null || !cursor.moveToFirst())
            {
                if(cursor != null)
                    cursor.close();
                i = 0;
            } else
            {
                i = cursor.getCount();
                cursor.close();
            }
        }
        return i;
    }

    public static void b(Context context, String s, LinkedList linkedlist)
    {
        if(!TextUtils.isEmpty(s) && linkedlist != null && !linkedlist.isEmpty())
        {
            StringBuilder stringbuilder = new StringBuilder();
            Iterator iterator = linkedlist.iterator();
            do
            {
                if(!iterator.hasNext())
                    break;
                cls_u u1 = (cls_u)iterator.next();
                if(u1 != null)
                    stringbuilder.append("'").append(u1.V()).append("'").append(",");
            } while(true);
            if(stringbuilder.length() > 0)
                stringbuilder.deleteCharAt(-1 + stringbuilder.length());
            c(context, s, stringbuilder.toString());
        }
    }

    public static boolean b(Context context, String s, String s1)
    {
        boolean flag;
        if(context == null || TextUtils.isEmpty(s) || s1 == null)
        {
            flag = false;
        } else
        {
            String s2 = (new StringBuilder()).append("account = '").append(s).append("' AND ").append("uid").append(" = '").append(s1).append("'").toString();
            Cursor cursor = context.getContentResolver().query(e.b, a, s2, null, null);
            if(cursor == null || !cursor.moveToFirst())
            {
                if(cursor != null)
                    cursor.close();
                flag = false;
            } else
            {
                cursor.close();
                flag = true;
            }
        }
        return flag;
    }

    public static void c(Context context, String s)
    {
        String s1 = (new StringBuilder()).append("account = '").append(s).append("'").toString();
        context.getContentResolver().delete(e.b, s1, null);
    }

    private static void c(Context context, String s, String s1)
    {
        if(context != null && !TextUtils.isEmpty(s) && s1 != null)
        {
            String s2 = (new StringBuilder()).append("account = '").append(s).append("' AND ").append("uid").append(" in ").append("(").append(s1).append(")").toString();
            context.getContentResolver().delete(e.b, s2, null);
        }
    }

    static String a[];
    public static final int b = 0;
    public static final int c = 1;
    public static final int d = 2;
    public static final int e = 3;
    private static String f[];

    static 
    {
        String as[] = new String[4];
        as[0] = "_id";
        as[1] = "account";
        as[2] = "uid";
        as[3] = "other";
        a = as;
        String as1[] = new String[1];
        as1[0] = "uid";
        f = as1;
    }
}
